{include file="public/meat" title="微信菜单管理"/}
<div class="cx-fex-c">
    <div class="x11 pad-t25">
        <form class="layout layui-form" role="form" action="" method="post">
            <div class="layout cx-fex-l">
                <div class="xs6 xl12 cx-fex-c fex-items-c">
                    <div class="wx-iphone pos-r">
                        <ul class="cx-fex wx-menu pos-a">
                            {volist name="menus.menu.button" id="cx" empty=""}
                            <li class="pos-r wxmenuadd{$i}" data-zmenu="{$i}">
                                <span class="wxmenuedit cx-click" data-type="wxeditmenu" data-cid="wxmenuedit{$i}">{$cx.name}</span>
                                <ul class='wx-menu-two cx-fex-c fex-column pos-a'>
                                {present name="cx.sub_button"}
                                {volist name="cx.sub_button" id="c" empty="" key="k"}
                                    <li class="pos-r wxmenuadd-two{$i}{$k}" data-zmenu="{$i}{$k}"><span class='wxmenuedit cx-click' data-type='wxeditmenu' data-zmenu="{$i}{$k}" data-cid="wxmenuedit-two{$i}{$k}">{$c.name}</span></li>
                                {/volist}
                                {/present}
                                </ul>
                            </li>
                            {/volist}
                        </ul>
                    </div>
                    <div class="layout t-c mt-20">
                        <input type="hidden" name="id" class="ipt wx-ipt" value="{$menus.id|default=''}">
                        <button class="button bg-blue mr-10" data-save="0" lay-submit lay-filter="wxmenusave">仅保存</button>
                        <button class="button bg-blue" data-save="1" lay-submit lay-filter="wxmenusave">保存并发布</button>
                    </div>
                </div>
                <div class="xs6 xl12" id="wxedit">
                    {volist name="menus.menu.button" id="cx" empty=""}
                    <div class="layout wx-menuedit wxmenuedit{$i}" style="display: none">
                        <div class="layout cx-fex wx-menu-top">
                            <h3>编辑菜单</h3>
                            <span class="button bg-red cx-click" data-type="wxdelmenu" data-cid="wxmenuadd{$i}">删除菜单</span>
                        </div>
                        <div class="cx-fex-l mb-15">
                            <div class="x3 t-r">
                                <label class="lab">菜单名称</label>
                            </div>
                            <div class="xs8 xl9" data-cid="wxmenuadd{$i}">
                                <input type="text" name="button[{$i}][name]" class="ipt wx-ipt" placeholder="菜单名称" value="{$cx.name}">
                            </div>
                        </div>
                        {notpresent name="cx.sub_button"}
                        <div class="cx-fex-l menuradio mb-15">
                            <div class="x3 t-r">
                                <label class="lab">菜单内容</label>
                            </div>
                            <div class="xs8 xl9">
                                <input class="menur{$i}" name="button[{$i}][type]" type="radio" value="view" {eq name="cx.type|default='view'" value="view"}checked="checked"{/eq} title="网页链接" lay-filter="wxmenuclass" data-num="button[{$i}]">
                                <input class="menur{$i}" name="button[{$i}][type]" type="radio" value="miniprogram" {eq name="cx.type|default=''" value="miniprogram"}checked="checked"{/eq} title="小程序" lay-filter="wxmenuclass" data-num="button[{$i}]">
                            </div>
                        </div>
                        <div class="layout menuradiotext">
                            <div class="cx-fex-l mb-15">
                                <div class="x3 t-r"><label class="lab">页面地址</label></div>
                                <div class="xs8 xl9">
                                    <input type="text" name="button[{$i}][url]" class="ipt" laceholder="" value="{$cx.url|default=''}">
                                    <span class="t-gray">请输入带"http://"的链接地址</span>
                                </div>
                            </div>
                        </div>
                        {/notpresent}
                    </div>
                    {present name="cx.sub_button"}
                    {volist name="cx.sub_button" id="c" empty="" key="k"}
                    <div class="layout wx-menuedit wxmenuedit-two{$i}{$k}" style="display: none">
                        <div class="layout cx-fex wx-menu-top">
                            <h3>编辑子菜单</h3>
                            <span class="button bg-red cx-click" data-type="wxdelmenu" data-cid="wxmenuadd-two{$i}{$k}">删除子菜单</span>
                        </div>
                        <div class="cx-fex-l mb-15">
                            <div class="x3 t-r"><label class="lab">子菜单名称</label></div>
                            <div class="xs8 xl9" data-cid="wxmenuadd-two{$i}{$k}">
                                <input type="text" name="button[{$i}][sub_button][{$k}][name]" class="ipt wx-ipt" placeholder="子菜单名称" value="{$c.name}">
                            </div>
                        </div>
                        <div class="cx-fex-l menuradio mb-15">
                            <div class="x3 t-r"><label class="lab">子菜单名称</label></div>
                            <div class="xs8 xl9">
                                <input class="menur{$i}{$k}" name="button[{$i}][sub_button][{$k}][type]" type="radio" value="view" {eq name="c.type" value="view"}checked="checked"{/eq} title="网页链接" lay-filter="wxmenuclass" data-num="button[{$i}][sub_button][{$k}]">
                                <input class="menur{$i}{$k}" name="button[{$i}][sub_button][{$k}][type]" type="radio" value="miniprogram" {eq name="c.type" value="miniprogram"}checked="checked"{/eq} title="小程序" lay-filter="wxmenuclass" data-num="button[{$i}][sub_button][{$k}]"></div>
                        </div>
                        <div class="layout menuradiotext">
                            <div class="cx-fex-l mb-15">
                                <div class="x3 t-r">
                                    <label class="lab">页面地址</label>
                                </div>
                                <div class="xs8 xl9">
                                    <input type="text" name="button[{$i}][sub_button][{$k}][url]" class="ipt" placeholder="" value="{$c.url}">
                                    <span class="t-gray">请输入带"http://"的链接地址</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    {/volist}
                    {/present}
                    {/volist}
                </div>
            </div>
        </form>
    </div>
</div>
<div style="height: 20px; overflow: hidden"></div>
{include file="public/js" /}
<script>
    layui.config({
        base: '__ADMIN__/js/'
    }).use('app');
</script>
<script>
    $("#all").click(function () {
        $(this).closest("table").find("td.alltd input:checkbox").prop("checked",$(this).prop("checked"))
    });
    var w = $('.wx-iphone').width();
    $('.wx-iphone').height(w / 0.5625);
    $('.wx-menu').each(function () {
        var mnum = $(this).children('li').length;
        if(mnum < 3){
            $(this).append("<li class='wxmenuadd cx-click' data-type='wxmenu' data-leng='3' data-mc='1'>+ 添加菜单</li>");
        }
    });
    $('.wx-menu-two').each(function () {
        var mnum = $(this).children('li').length;
        if(mnum < 5){
            $(this).append("<li class='wxmenuadd cx-click' data-type='wxmenu' data-leng='5'>+ 添加子菜单</li>");
        }
    });
    $("#wxedit").on('change','.wx-ipt',function(){
        var cid = $(this).parent().data('cid');
        $('.'+cid).children('span').text($(this).val());
    });
</script>
{include file="public/footer" /}